public class 凑算式标记dfs {
	public static double[] a = new double[9];
	public static int[] visited = new int[] {0,0,0,0,0,0,0,0,0}; // 9个0
	public static int count = 0;
	public static void dfs(int index) {
		// 结束条件
		if(index == 9) {
			if(a[0]+a[1]/a[2]+(a[3]*100+a[4]*10+a[5])/(a[6]*100+a[7]*10+a[8]) == 10)
				count++;
			return;
		} else {
			for(int i=1; i<=9; i++) {
				if(visited[i-1] == 0) { // 因为i从1开始，所以需要 -1
					visited[i-1] = 1; // 标记
					a[index] = (double)i;
					dfs(index+1);
					visited[i-1] = 0; // 清除标记
				}
			}
		}
	}





	public static void main(String[] args) {
		dfs(0);
		System.out.println(count);
	}












}